﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;

using Kwan.Data;
using BG.Data;

namespace BG.Service
{
	public class ProductClassQuery
	{

		public static Expression MakeSearchWhere(NameValueCollection ps)
		{
			Expression exp = new Expression();

            string propName = "EntityID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TProductClass.entityID == int.Parse(ps[propName]);

			propName = "nameCN";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProductClass.nameCN == ps[propName];
			}
			propName = "nameEN";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProductClass.nameEN == ps[propName];
			}
			propName = "pid";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProductClass.pid == int.Parse(ps[propName]);
			}
			propName = "sort";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProductClass.sort == int.Parse(ps[propName]);
			}

			return exp;
		}
	}
}